package com.bright.tactiviti.process.start;

import org.activiti.engine.RuntimeService;
import org.activiti.engine.runtime.Execution;
import org.activiti.engine.runtime.ExecutionQuery;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.List;

/**
 * 执行实例
 */
@SpringBootTest
public class ExecutionNote {
    @Autowired
    private RuntimeService runtimeService;

    /**
     * 查询执行实例
     * 操作对应数据表
     * ACT_RU_EXECUTION
     *
     */

    @Test
    public void executionQuery(){
        //获取 执行实例 查询器
        ExecutionQuery executionQuery = runtimeService.createExecutionQuery();

        List<Execution> executions = executionQuery.list();

        executions.forEach(execution -> {
            System.out.println("执行实例ID：" + execution.getId());
            System.out.println("执行实例Name:" + execution.getName());
            System.out.println("父节点ID：" + execution.getParentId());
            System.out.println("流程实例ID：" + execution.getProcessInstanceId());
            System.out.println("======================");
        });
    }
}
